// Copyright (c) Appeon. All rights reserved.
// Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. 
// You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0.

using System;

namespace SnapObjects.Data.Oracle
{
    internal class OracleSqlStatementFactory : SqlStatementFactory
    {
        public OracleSqlStatementFactory(ISqlGenerationHelper helper, ITypeMapper mapper)
            : base(helper, mapper)
        {
        }

        public override ISqlBuilderParser GetBuilderParser(SqlStatementType statementType)
        {
            switch (statementType)
            {
                case SqlStatementType.Select:
                {
                    return new OracleQueryBuilderParser(this, _helper, _mapper);
                }
                case SqlStatementType.SqlRaw:
                {
                    return new OracleRawBuilderParser(this, _helper, _mapper);
                }
                case SqlStatementType.Insert:
                {
                    return new OracleInsertBuilderParser(this, _helper, _mapper);
                }
                case SqlStatementType.Update:
                {
                    return new OracleUpdateBuilderParser(this, _helper, _mapper);
                }
                case SqlStatementType.Delete:
                {
                    return new OracleDeleteBuilderParser(this, _helper, _mapper);
                }
                case SqlStatementType.Procedure:
                {
                    return new OracleProcedureBuilderParser(this, _helper, _mapper);
                }
                case SqlStatementType.Condition:
                {
                    return new OracleConditionBuilderParser(this, _helper, _mapper);
                }
                case SqlStatementType.Function:
                {
                    return new OracleFunctionBuilderParser(this, _helper, _mapper);
                }
                default:
                {
                    throw new NotSupportedException(statementType.ToString());
                }
            }
        }

        public override ISqlStatementGenerator GetSqlGenerator(SqlStatementType statementType)
        {
            ISqlStatementGenerator generator;

            switch (statementType)
            {
                case SqlStatementType.Select:
                {
                    generator = new OracleSqlSelectStatementGenerator(this, _helper, _mapper);
                }
                break;
                case SqlStatementType.Insert:
                {
                    generator = new OracleSqlInsertStatementGenerator(this, _helper, _mapper);
                }
                break;
                case SqlStatementType.Update:
                {
                    generator = new OracleSqlUpdateStatementGenerator(this, _helper, _mapper);
                }
                break;
                case SqlStatementType.Delete:
                {
                    generator = new OracleSqlDeleteStatementGenerator(this, _helper, _mapper);
                }
                break;
                case SqlStatementType.Procedure:
                {
                    generator = new OracleSqlProcedureStatementGenerator(this, _helper, _mapper);
                }
                break;
                case SqlStatementType.Condition:
                {
                    generator = new OracleSqlConditionStatementGenerator(this, _helper, _mapper);
                }
                break;
                case SqlStatementType.SqlRaw:
                {
                    generator = new OracleSqlRawStatementGenerator(this, _helper, _mapper);
                }
                break;
                case SqlStatementType.Function:
                {
                    generator = new OracleSqlFunctionStatementGenerator(this, _helper, _mapper);
                }
                break;
                default:
                {
                    throw new NotSupportedException(statementType.ToString());
                }
            }

            return generator;
        }

        public override ISqlStatementParser GetSqlParser(SqlStatementType statementType)
        {
            ISqlStatementParser parser;

            switch (statementType)
            {
                case SqlStatementType.Select:
                {
                    parser = new OracleSqlSelectStatementParser(this, _helper);
                }
                break;
                case SqlStatementType.Delete:
                {
                    parser = new OracleSqlDeleteStatementParser(this, _helper);
                }
                break;
                case SqlStatementType.Update:
                {
                    parser = new OracleSqlUpdateStatementParser(this, _helper);
                }
                break;
                case SqlStatementType.Insert:
                {
                    parser = new OracleSqlInsertStatementParser(this, _helper);
                }
                break;
                case SqlStatementType.Procedure:
                {
                    parser = new OracleSqlProcedureStatementParser(this, _helper);
                }
                break;
                case SqlStatementType.SqlRaw:
                {
                    parser = new OracleSqlRawStatementParser(this, _helper);
                }
                break;
                case SqlStatementType.Function:
                {
                    parser = new OracleSqlFunctionStatementParser(this, _helper);
                }
                break;
                default:
                {
                    throw new NotSupportedException(statementType.ToString());
                }
            }

            return parser;
        }
    }
}
